package de.rts.ui;

import javax.swing.JInternalFrame;
import javax.swing.JScrollPane;

public class RailwayMapIFrame extends JInternalFrame
{
  /**
   * 
   */
  private static final long serialVersionUID = 1L;
  static int                mapWidth         = RailwaySimulatorFrame.appWidth * 3 / 4;
  static int                mapHeight        = RailwaySimulatorFrame.appHeight - RailwaySimulatorFrame.inset - 10;
  private RailwayMapPanel           railwayMap;
  private JScrollPane scrollPane;

  public RailwayMapIFrame()
  {
    super("Railway Map", true, false, true, true);
    setSize(mapWidth, mapHeight);
    setLocation(0, 0);
    scrollPane = new JScrollPane();
    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    getContentPane().add(scrollPane);
  }

  protected void setMapContent(RailwayMapPanel railwayMap)
  {
    if (railwayMap == null) throw new NullPointerException(railwayMap + " can't be null");
    this.railwayMap = railwayMap;
    scrollPane.setViewportView(this.railwayMap);
    revalidate();
  }

  protected void removePanelContent(RailwayMapPanel railwayMap)
  {
    remove(this.railwayMap);
    setMapContent(railwayMap);
  }
}
